﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Logistics.Control
{
    /// <summary>
    /// Interaction logic for NumKeyboard.xaml
    /// </summary>
    public partial class NumKeyboard : UserControl
    {
        public NumKeyboard()
        {
            InitializeComponent();
        }

        private void BtnKey_Click(object sender, RoutedEventArgs e)
        {
            Button Btn = sender as Button;
            String text = Btn.Content as String;
            if (text == "回退")
                text = "{BACKSPACE}";
            if (text == "清除")
                text = "{DELETE}";
            if (text == "确定")
                text = "{ENTER}";

            String key = text;
            UIElement element = Keyboard.FocusedElement as UIElement;
            if (element != null)
            {
                element.Dispatcher.BeginInvoke(new Action(() =>
                {
                    System.Windows.Input.Test.SendKeys.Send(element, key);
                }), System.Windows.Threading.DispatcherPriority.Input);
            }
        }
    }
}
